﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Laharsub.Server.Wcf
{
    static class HttpAPIDocumentation
    {
        public const string Park =
            @"This API accepts an HTTP request and never sends a reponse. " +
            "It can be used to measure the maximum number of concurrent client connections the server can support on a single machine.";

        public const string CreateTopic =
            @"This API creates a new pub/sub topic. The request does not specify any parameters. "+
            "The response content type is 'text/plain' and the body contains a single integer representing the unique topicId "+
            "of the newly created topic.";

        public const string Publish =
            @"This API publishes a new message to a topic. The request URL specifies the topicId of the topic the message should be published to. "+
            "The request body along with the Content-type header specify the message to be published. The response content type is 'text/plain' "+
            "and the response body contains a single integer representing the unique messageId of the newly published message. Message IDs are guranateed to "+
            "increase in value following the order in which publication requests were received.";

        public const string Subscribe =
            @"This API subscribes to messages published to one or more topics. The request is an HTTP long poll: the server responds when messages "+
            "matching the subscription parameters are (or become) available, or after a timeout configured on the server is reached, whichever comes first. "+
            "The request must provide subscription parameters for one or more topics in the form of an array of subscription speficiations encoded as URL parameters. "+
            "For each topic to be subscribed to, a URL parameter of the form subs[{x}][topicid]={topicId} must be specified, "+
            "where {x} is an zero-based array index of the subscription specification, and {topicId} is a positive integer identifying the topic. "+
            "For example, a subscription request for a single topic identified with topicId 1234 would have to provide the following URL paramater: "+
            "subs[0][topicid]=1234. Each subscription specification may also provide an optional messageId value, which specifies the minimum message ID within a topic "+
            "the client is interested in receiving. This optional constraint may be specified as a URL parameter of the form subs[{x}][from]={messageId}, "+
            "where {x} is a zero-based array index of the subscription specification, and {messageId} is a positive integer identifying the minimum messageId of "+
            "messages published to the topic which are requested. For example, a subscription request for single topic identified with topicId 1234 that includes "+
            "all messages with messageId greater or equal 2767 would have to provide the following URL query: subs[0][topicid]=1234&subs[0][from]=2767. "+
            "In the absence of the optional messageId parameter, only messages published to the topic after the subscription request was received will match the subscription. "+
            "(This format of URL parameters happens to be the same as the result of encoding a JavaScript array of objects using the jQuery.param function). "+
            "In case the subscription request times out without a matching messages becoming available on the server, the HTTP response will be empty and the status code 200. "+
            "In case a message or messages that match the subscription request are or become available before the timeout is reached, an HTTP response is sent immediately. "+
            "The content type of the response if 'multipart/mixed; boundary={boundary}', and the body of the response contains all messages "+
            "matching the subscription request. Each MIME part of the multipart/mixed body contains a single message. Each MIME part contains the Content-type header "+
            "matching the content type of the message specified upon its publishing. Each MIME part also contains the Content-Description header with the value "+
            "of {topicId}/{messageId}, where {topicId} and {messageId} are positive integers representing the topic ID and message ID of the message contained in the MIME part, respectively. "+
            "The body of each MIME part contains the actual message. ";
    }
}
